
apiVersion: v1
kind: DeploymentConfig
metadata:
  name: waiverdb-web
  labels:
    app: waiverdb
    service: web
spec:
  replicas: 2
  selector:
    app: waiverdb
    service: web
{% if env == 'staging' %}
  strategy:
    type: Rolling
    rollingParams:
      pre:
        failurePolicy: Abort
        execNewPod:
          containerName: web
          command: [ /bin/sh, -i, -c, "waiverdb wait-for-db && waiverdb db upgrade" ]
          volumes:
          - config-volume
          - secret-volume
{% endif %}
  template:
    metadata:
      labels:
        app: waiverdb
        service: web
    spec:
      containers:
      - name: web
        image: waiverdb
        ports:
        - containerPort: 8080
        volumeMounts:
        - name: config-volume
          mountPath: /etc/waiverdb
          readOnly: true
        - name: fedmsg-config-volume
          mountPath: /etc/fedmsg-waiverdb.d
          readOnly: true
        - name: secret-volume
          mountPath: /etc/secret
          readOnly: true
        - name: fedmsg-key-volume
          mountPath: /etc/pki/fedmsg/key
          readOnly: true
        - name: fedmsg-crt-volume
          mountPath: /etc/pki/fedmsg/crt
          readOnly: true
        env:
        - name: DATABASE_PASSWORD
          valueFrom:
            secretKeyRef:
              name: waiverdb-secret
              key: database-password
        - name: SECRET_KEY
          valueFrom:
            secretKeyRef:
              name: waiverdb-secret
              key: flask-secret-key
        readinessProbe:
          timeoutSeconds: 1
          initialDelaySeconds: 5
          httpGet:
            path: /healthcheck
            port: 8080
        livenessProbe:
          timeoutSeconds: 1
          initialDelaySeconds: 30
          httpGet:
            path: /healthcheck
            port: 8080
        resources:
          limits:
            memory: 384Mi
      volumes:
      - name: config-volume
        configMap:
          name: waiverdb-configmap
      - name: fedmsg-config-volume
        configMap:
          name: waiverdb-fedmsg-configmap
      - name: secret-volume
        secret:
          secretName: waiverdb-secret
      - name: fedmsg-key-volume
        secret:
          secretName: waiverdb-fedmsg-key
      - name: fedmsg-crt-volume
        secret:
          secretName: waiverdb-fedmsg-crt
  triggers:
  - type: ImageChange
    imageChangeParams:
      automatic: true
      containerNames:
      - web
      from:
        kind: ImageStreamTag
        name: waiverdb:latest
  - type: ConfigChange
